<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="query">
				<el-form-item>
					<el-input v-model="query.keyword" placeholder="关键字"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="serach">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="pageInfo.rows" highlight-current-row v-loading="listLoading" style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column type="index" width="60">
			</el-table-column>
			<el-table-column prop="name" label="权限名" width="120" sortable>
			</el-table-column>
			<el-table-column prop="descs" label="描述" width="200"  sortable>
			</el-table-column>
			<el-table-column prop="sn" label="唯一标识" width="250" sortable>
			</el-table-column>
			<el-table-column prop="url" label="路径" width="250" sortable>
			</el-table-column>
			<el-table-column prop="parent.name" label="父级权限名" min-width="180" sortable>
			</el-table-column>
		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination layout="total,prev, pager, next" @current-change="handleCurrentChange"
                     :page-size="query.pageSize"
                     :total="pageInfo.total"
                     :current-page="query.currentPage"
                     style="float:right;">
			</el-pagination>
		</el-col>


	</section>
</template>

<script>
	export default {
		data() {
			return {

				listLoading: false,
				sels: [],//列表选中列

				query:{
				  currentPage:1,
          pageSize:10,
          keyword:""
        },
        pageInfo:{
				  total:0,
          rows:[]
        }
			}
		},
		methods: {

			handleCurrentChange(val) {
				this.query.currentPage = val;
				this.getUsers();
        console.log(this.pageInfo)
        console.log(this.query)
			},
			//获取用户列表
			getUsers() {
			this.$http.post("/permission",this.query)
        .then(result=>{
          result=result.data;
          if (result.success){
            this.pageInfo=result.data;
          }else {
            this.$message({message: '后端错误', type: 'error'});
          }
        })
        .catch(()=>{
          this.$message({message: '系统超时', type: 'error'});
        })
			},
      serach(){
			  this.query.currentPage=1;
			  this.getUsers();
      }




		},
		mounted() {
			this.getUsers();
		}
	}

</script>

<style scoped>

</style>